import core from "./core/core.js";
import MMask from "./common/MMask"
import MToast from './common/MToast';
import MGroup from './common/MGroup';

import MButton from './components/MButton';
import MRadio from './components/MRadio';
import MCheckbox from './components/MCheckbox';
import MForm from './components/MForm';

import MModal from './components/MModal';

const options = {
    core,
    MMask,
    MToast,
    MGroup,

    MButton,
    MRadio,
    MCheckbox,
    MForm,

    MModal
};

options.install = (Vue) => {
    // if (global.Vue !== Vue) {
    //     global.Vue = Vue;
    // }

    for (let component in options) {
        const componentInstaller = options[component];

        if (componentInstaller && component !== 'install') {
            Vue.use(componentInstaller);
        }
    }

    if (!!document) {
        var mirror = document.createElement("div");
        mirror.appendChild(document.createElement("m-toast"));

        document.body.appendChild(mirror);
        Vue.prototype.mirror.root = new Vue({
            el: mirror
        });
    }

    // Vue.mirror = Vue.prototype.mirror;
};

module.exports = options;